package com.recruit.g1.user.dao.mapper;

import com.recruit.g1.pojo.user.dto.UserRegParam;
import com.recruit.g1.pojo.user.entity.User;
import com.recruit.g1.pojo.user.vo.UserSaveParam;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    @Insert("INSERT INTO user (username, password) VALUES (#{username}, #{password})")
    void insert(UserRegParam userRegParam);

    @Select("select id,username,password from user  where username = #{username} and password = #{password}")
    User selectByUsernameAndPassword(@Param("username") String username,
                                     @Param("password") String password);

    @Select("select id,username,password from user  where username = #{username}")
    UserSaveParam selectByUsername(@Param("username") String username);

    @Update("UPDATE user SET password = #{newPassword}   WHERE username = #{username}    AND password = #{oldPassword}")
    int updatePassword(@Param("username") String username,
                       @Param("oldPassword") String oldPassword,
                       @Param("newPassword") String newPassword);
}